package fun.util.daohelper.hibernate.expression;

import fun.util.daohelper.expression.GreaterThan;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

/**
 * Author: binz
 * Date: Jul 24, 2006
 * Time: 1:24:15 PM
 */
public class GreaterThanTransformer implements ExpressionCriterionTransformer<GreaterThan> {

    public Criterion transform( GreaterThan greaterThan ) {
        if ( greaterThan.isAndEqualTo() ) {
            return Restrictions.ge( greaterThan.getFieldName(), greaterThan.getValue() );
        } else {
            return Restrictions.gt( greaterThan.getFieldName(), greaterThan.getValue() );
        }
    }
}
